#include <stdio.h>
#include <string.h>

int gcd( __int64 a, __int64 b )
{
    while ( b )
    {
        __int64 rem = a % b;
        a = b;
        b = rem;
    }
    return a;
}

int main( )
{
    char num[ 14 ];
    int t;
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%s", num);
        __int64 a = 1, b = 1, i, x = 0, y = 0, t1, t2, t3;
        bool kuohao = false;
        for ( i = 2; i < strlen( num ); i++ )
        {
            if ( num[ i ] ==')' ) break;
            if ( num[ i ] =='(' )
            {
                kuohao = true;
                continue;
            }
            if ( kuohao )
            {
                b *= 10;
                y = y * 10 + num [ i ] - '0';
            }
            else
            {
                a *= 10;
                x = x * 10 + num[ i ] - '0';
            }
        }
        if ( kuohao )
        {
            t1 = x * b + y;
            t1 -= x;
            t2 = b * a - a;
            t3 = gcd( t1, t2 );
            printf("%I64d/%I64d\n", t1 / t3, t2 / t3);
        }
        else
        {
            t3 = gcd( x, a );
            printf("%I64d/%I64d\n", x / t3, a / t3);
        }
    }
    return 0;
}
